﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _16_Jan_Practice
{
    class Bank
    {
        Account customerAccount;
        private List <Account> listOfAccounts = new List<Account>();
        public void CreateAccount()
        {
            customerAccount=new Account();
            listOfAccounts.Add(customerAccount);
            Console.WriteLine("Account is created");
        }
        public void GetMoney(int i)
        {
            foreach (Account account in listOfAccounts)
            {
                if (account.id == i)
                {
                    Console.WriteLine("Enter amount of money");
                    decimal money = Decimal.Parse(Console.ReadLine());
                    if (money > 0)
                    {
                        account.money = money;
                        Console.WriteLine("Funds are added");
                    }
                    else
                    {
                        Console.WriteLine("error");
                    }
                }
            }
        }
        public void ShowMoneyOnAccount(int i)
        {
            foreach (Account item in listOfAccounts)
            {
                if (item.id == i)
                {
                    Console.WriteLine("{0}$", item.money);
                }
            }
        }
        public void DeleteAccount(int i)
        {
            for (int j = 0; j < listOfAccounts.Count; j++)
            {
                if (listOfAccounts[j].id==i)
                {
                    listOfAccounts.Remove(listOfAccounts[j]);
                    Console.WriteLine("Your account is deleted");
                }
            }
        }
        public decimal GetAllMoney(int i)
        {
            decimal d = 0;
            foreach (Account item in listOfAccounts)
            {
                if (item.id == i)
                {
                    if (item.money > 0)
                    {
                        d = item.money;
                        item.MoneyAmount = -d;
                        Console.WriteLine("You have got all your money");
                    }
                }
            }
            return d;
        }
    }
}
